package cn.tedu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author 董代恒
 * @version 1.0
 */
@Component
public class ShopController {

    private String title;

    public ShopController() {
        System.out.println("1.初始化");
    }

    @Value("你好")
    public void setTitle(String title) {
        System.out.println("2.属性赋值");
        this.title = title;
    }

    public ShopController(String title) {
        System.out.println("有参方法");
        this.title = title;
    }

    @PostConstruct
    public void init(){
        System.out.println("3.生命周期初始化方法");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("5.生命周期销毁方法");
    }
}
